package oop.core.skill;

import oop.core.map.*;

import java.util.*;

/**
 * Radial skill creates a set of temporal locations spreading
 * out from the Avatar's location.
 */
public class Radial extends ActiveSkill implements Cloneable{
	
	/**
	 * Constructor for Radial.
	 * @param name
	 * @param skillLevel
	 * @param lifeTime
	 * @param hitCount
	 * @param effect
	 * @param image
	 * @param delay
	 * @param range
	 * @param passiveSkillsThatAffectMe
	 * @param weaponType
	 */
	public Radial(String name, int skillLevel, long lifeTime, long hitCount, float effect, String image, long delay, int range, List<String> passiveSkillsThatAffectMe, List<String> weaponType){
		super(name, skillLevel, lifeTime, hitCount, effect, image, delay, range, passiveSkillsThatAffectMe, weaponType);
	}
	
	/**
	 * Return the set of temporal locations surrounding an intial location
	 * representing the user's (of the ActivateSkill) location.
	 * @param location
	 * @param direction
	 */
	public List<TemporalLocation> calculateLocationSet(Location location, int direction){
		List<TemporalLocation> ret = new ArrayList<TemporalLocation>();
		for(int i = -1*range;i<=range;i++){
			for(int j = -1*range;j<=range;j++){
				Location l = new Location(i,j);
				// case of radius 1 (all 9 squares around caster)
				if(i<=1 && i>=-1 && j<=1 && j>=-1)
					ret.add(new TemporalLocation(Location.add(l, location),0));
				// case of diagonal
				else if(Math.abs(i) == Math.abs(j)){
					if(Math.abs(j) < range)
						ret.add(new TemporalLocation(Location.add(l, location), (Math.abs(j)+1)*propogationDelay));
				}
				// everything else
				else{
					ret.add(new TemporalLocation(Location.add(l, location), (Math.max(Math.abs(i), Math.abs(j)))*propogationDelay));
				}
			}
		}
		return ret;
	}
	
	/**
	 * Implement clone.
	 */
	public Radial clone(){
		Radial cloned = (Radial)super.clone();
		return cloned;	
	}
}
